package co.yixiang.modules.user.rest;
import co.yixiang.api.ApiResult;
import co.yixiang.common.bean.LocalUser;
import co.yixiang.common.interceptor.AuthCheck;
import co.yixiang.modules.user.service.YxDistributorEarningsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author ycl
 * @date 2020-03-02
 */
@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(value = "用户提现", tags = "用户:用户提现", description = "用户提现")
public class UserDistributorController {


    private final YxDistributorEarningsService yxDistributorEarningsService;

    /**
     * 我的分销首页
     */
    @AuthCheck
    @GetMapping("/distributor/index")
    @ApiOperation(value = "我的分销首页",notes = "我的分销首页")
    public ApiResult<Object> index(@RequestParam(value = "page",defaultValue = "1") int page,
                                   @RequestParam(value = "limit",defaultValue = "10") int limit){
        return ApiResult.ok(yxDistributorEarningsService.index(LocalUser.getUser() , page , limit));
    }

    /**
     * 我的佣金明细
     */
    @AuthCheck
    @GetMapping("/distributor/detail")
    @ApiOperation(value = "我的佣金明细",notes = "我的佣金明细")
    public ApiResult<Object> detail(@RequestParam(value = "page",defaultValue = "1") int page,
                                   @RequestParam(value = "limit",defaultValue = "10") int limit){
        return ApiResult.ok(yxDistributorEarningsService.detail(LocalUser.getUser() , page , limit));
    }


    /**
     * 他人佣金明细
     */
    @AuthCheck
    @GetMapping("/distributor/otherDetail")
    @ApiOperation(value = "他人佣金明细",notes = "他人佣金明细")
    public ApiResult<Object> otherDetail(@RequestParam(value = "page",defaultValue = "1") int page,
                                         @RequestParam(value = "limit",defaultValue = "10") int limit,
                                         @RequestParam(value = "otherUid") Long otherUid){
        return ApiResult.ok(yxDistributorEarningsService.otherDetail(LocalUser.getUser() , otherUid , page , limit));
    }

}
